package com.dhms.vostok1.service.net

import com.dhms.vostok1.data.*
import com.dhms.vostok1.data.abnormals.SpotSource
import retrofit2.Response
import retrofit2.http.*

private const val mock_prefix = "mock/1265123"
private const val API_PREFIX_SPOTPATROL = "spot-patrol"
private const val API_PREFIX_DEVICEHUB = "devicehub"


interface IMockNetworkAPI {
    @GET("$mock_prefix/$API_PREFIX_SPOTPATROL/task-groups")
    suspend fun getTaskGroups(
        @Query("offset") offset: Int,
        @Query("limit") limit: Int,
        @Query("query_task_type") query_task_type: String? = null,
        @Query("query_task_status") query_task_status: String? = null,
    ): Response<BaseResData<TaskGroupsResData>>

    @GET("$mock_prefix/$API_PREFIX_SPOTPATROL/task/{group_id}/{task_id}")
    suspend fun getTaskDetail(
        @Path("group_id") group_id: String,
        @Path("task_id") task_id: String
    ): Response<TaskResData>

    @PUT("$mock_prefix/$API_PREFIX_SPOTPATROL/task")
    suspend fun updateTask(@Body body: TaskUpdateReqBody): Response<BaseResData<Any>>

    @PUT("$mock_prefix/$API_PREFIX_SPOTPATROL/task-group/executors/{group_id}")
    suspend fun updateGroupExecutors(
        @Path("group_id") group_id: String,
        @Body body: TaskExecutorsReqBody
    ): Response<BaseResData<Any>>

    @GET("$mock_prefix/$API_PREFIX_SPOTPATROL/task-group/{group_id}")
    suspend fun getTaskGroupDetail(@Path("group_id") group_id: String): Response<TaskGroupResData>

    /*异常记录*/

    @GET("$mock_prefix/$API_PREFIX_DEVICEHUB/abnormals")
    suspend fun getAbnormals(
        @Query("page") page: Int,
        @Query("per_page") per_page: Int,
        @Query("start_time") start_time: Long? = null,
        @Query("end_time") end_time: Long? = null,
        @Query("device_ids") device_ids: String? = null,
        @Query("status") status: String? = null,
        @Query("source") source: SpotSource? = null,
    ): Response<AbnormalsResData>

    @POST("$mock_prefix/$API_PREFIX_DEVICEHUB/abnormals")
    suspend fun createAbnormals(@Body body: AbnormalsCreateReqBody): Response<BaseResData<Any>>

    @GET("$mock_prefix/$API_PREFIX_DEVICEHUB/abnormals/{id}")
    suspend fun getAbnormalsDetail(
        @Path("id") id: String
    ): Response<AbnormalDetailResData>

    @POST("$mock_prefix/$API_PREFIX_DEVICEHUB/abnormals/{id}")
    suspend fun updateAbnormalsDetail(
        @Path("id") id: String,
        @Body body: AbnormalsUpdateReqBody
    ): Response<BaseResData<Any>>

    @GET("$mock_prefix/$API_PREFIX_DEVICEHUB/spot/abnormal-items")
    suspend fun getAbnormalsItems(
        @Query("page") page: Int,
        @Query("per_page") per_page: Int = 40,
    ): Response<AbnormalItemsResData>

    @POST("$mock_prefix/$API_PREFIX_DEVICEHUB/spot/abnormal-items")
    suspend fun createAbnormalsItems(
        @Body body: AbnormalItemsReqBody
    ): Response<BaseResData<Any>>

    @DELETE("$mock_prefix/$API_PREFIX_DEVICEHUB/spot/abnormal-items/{id}")
    suspend fun deleteAbnormalsItems(
        @Path("id") id: String,
    ): Response<BaseResData<Any>>
}